<template>
  <div class="maxbox">
    <div
      class="list"
      v-show="flag == 0 || flag == v.status"
      v-for="(v, i) in list"
      :key="i"
    >
      <div class="box">￥{{ v.price }}</div>
      <div>
        <p>{{ v.name }}</p>
        <p style="color:red;">{{ v.limit }}天内有效</p>
      </div>
      <div>
        <button v-if="v.status == 1" @click="cahnge(v.id)">去使用</button>
        <p v-else>已使用</p>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: ["list", "flag"],
  setup(props, { emit }) {
    function cahnge(v) {
      emit("cahngeOFF", v);
    }
    return {
      cahnge,
    };
  },
};
</script>

<style lang="scss" scoped>
.maxbox {
  padding: 0 15px 0 10px;
}
.list {
  width: 100%;
  height: 80px;
  background-color: #fff;
  display: flex;
  margin: 5px 0;
  border-radius: 8px;
  position: relative;
  .box {
    width: 90px;
    height: 80px;
    line-height: 80px;
    background-color: red;
    border-radius: 8px 0 0 8px;
    text-align: center;
  }
  div {
    &:nth-child(2) {
      height: 100%;
      display: flex;
      flex-direction: column;
      justify-content: space-around;
      margin: 0 10px 0 20px;
    }
    &:nth-child(3) {
      position: absolute;
      right: 14px;
      top: 52px;
    }
  }
}
</style>
